package com.blindnetworking;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.datastore.Entity;

public class Accept extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		String key = req.getParameter("key");
		Entity meeting;
		

		try {
			meeting = DBUtil.accept(key, true);
			
			System.out.println(meeting);
			
			String type = "";
			if (meeting != null)
				type = "accepted";
			else{
				meeting = DBUtil.getMeetingFromKey(key);
				type = "notChanged";
			}
			
			req.setAttribute("meeting", meeting);
			req.setAttribute("type", type);
						
		} catch (Exception e1) {
			e1.printStackTrace();
			req.setAttribute("type", "error");
		}
		
		try {
			req.getRequestDispatcher("/accept.jsp").forward(req, resp);
		} catch (ServletException e) {
			e.printStackTrace();
		}
	}

}
